<template>
    <Switch v-model="task_current.plan_sms" size="small" @on-change="handleAlarmPlanSMSChange(task_current)"></Switch>
</template>

<script>
export default {
    name: "AlarmPlanSMSSwitch",
    props: {
        data: Object
    },
    data() {
        return {
            task_current: this.data
        }
    },
    methods: {
        handleAlarmPlanSMSChange(row) {
            let plan_sms = row.plan_sms == true ? 1 : 0;
            this.$http.post('/alarm_plan_sms', { plan_id: row.plan_id, plan_sms: plan_sms }).then(res => {
                if (res.status == 'ok') {
                    this.$Message.success('切换成功');
                }else {
                    this.errorMessage(res.data);
                }
            }).catch(err => {
                this.errorMessage(err.data.data);
            });
        },
    }
}
</script>